package com.lzy.cloud.ticket.train.facade;

import com.lzy.cloud.ticket.train.constant.LMMApi;
import com.lzy.cloud.ticket.train.constant.LMMContant;
import com.lzy.cloud.ticket.train.dtos.TrainChangsDto;
import com.lzy.cloud.ticket.train.dtos.TrainOrderDto;
import com.lzy.cloud.ticket.train.remote.OrderApi;
import com.lzy.cloud.ticket.train.remote.request.OrderInfoRequest;
import com.lzy.cloud.ticket.train.request.*;
import com.lzy.cloud.ticket.train.request.app.*;
import com.lzy.cloud.ticket.train.response.BaseResponse;
import com.lzy.cloud.ticket.train.response.OrderDetailResponse;
import com.lzy.cloud.ticket.train.response.SearchResponse;
import com.lzy.cloud.ticket.train.servcie.TrainChangsService;
import com.lzy.cloud.ticket.train.util.BasePushUtil;
import com.lzy.framework.core.output.Result;
import com.lzy.framework.core.utils.DozerUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Component
@Slf4j
public class TrainFacade {

    @Resource
    private RestTemplate restTemplate;

    @Autowired
    private BasePushUtil basePushUtil;

    /**
     * 线下退款
     * @param orderOfflineRefundAppRequest
     * @return
     */
    public Result offlineRefund(OrderOfflineRefundAppRequest orderOfflineRefundAppRequest){
        BaseRequest baseRequest = basePushUtil.push(LMMContant.APP_KEY,LMMContant.OFFLINE_REFUND_METHOD,LMMContant.MESSAGE_FORMT,"");
        OrderOfflineRefundRequest orderOfflineRefundRequest = DozerUtils.map(baseRequest,OrderOfflineRefundRequest.class);
        orderOfflineRefundRequest.setData(orderOfflineRefundAppRequest);
        String response = restTemplate.postForObject(LMMApi.CHANGE_TICKET_URL,orderOfflineRefundRequest,String.class);
        return new Result("0",response);
    }

}
